package LeetCode;

class ListNode {
    int val;
    ListNode next = null;
}


public class LC203 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode dummy = new ListNode();
        dummy.next= head;
        ListNode temp = dummy;
        while (temp.next!=null){
            if(temp.next.val == val){
                temp.next = temp.next.next;
            } else{temp = temp.next;}
        }
        return dummy.next;
    }
}